# 1.打开浏览器
from time import sleep

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

service = Service(executable_path=r'E:\python\pythonshuju\chromedriver.exe')
driver = webdriver.Chrome(service=service)  #创建浏览器对象
# 2.输入访问地址（URL）
url = r"E:\pyCharm\PyCharm Pro 2024.1\PyCharmshuju\PycharmProjects\UI自动化测试\1\drop.html"
driver.get(url)
# 3.页面信息操作
# 实例化并获取ActionChains类
action = ActionChains(driver)

# 获取 源元素
source = driver.find_element(By.CSS_SELECTOR,"#div1")
# 获取 目标元素
target = driver.find_element(By.CSS_SELECTOR,"#div2")
sleep(3)
action.drag_and_drop(source, target).perform()
# 扩展 通过坐标偏移量执行
sleep(3)
action


# 4.关闭/退出浏览器
driver.quit()